/**
 * 
 */
package ads.engenharia.bl;

import java.sql.SQLException;
import java.util.ArrayList;

import ads.engenharia.dal.DisciplineDAO;
import ads.engenharia.dal.DisciplineProfessorDAO;
import ads.engenharia.dal.DisciplineScheduleDAO;
import ads.engenharia.entity.Discipline;

/**
 * @author Lanedraex
 *
 */
public class DisciplineBO {

	private DisciplineDAO disciplineDAO;
	private DisciplineScheduleDAO disciplineScheduleDAO;
	private DisciplineProfessorDAO disciplineProfessorDAO;

	/**
	 * 
	 * @param discipline
	 * @throws SQLException
	 */
	public void save(Discipline discipline) throws SQLException {

		disciplineDAO = new DisciplineDAO();
		disciplineScheduleDAO = new DisciplineScheduleDAO();
		disciplineProfessorDAO = new DisciplineProfessorDAO();

		discipline.id(disciplineDAO.save(discipline));
		disciplineScheduleDAO.save(discipline);
		disciplineProfessorDAO.save(discipline);
	}

	/**
	 * 
	 * @param discipline
	 * @throws SQLException
	 */
	public void delete(Discipline discipline) throws SQLException {

		disciplineDAO = new DisciplineDAO();
		disciplineDAO.delete(discipline);

	}

	/**
	 * 
	 * @param discipline
	 * @throws SQLException
	 */
	public void update(Discipline discipline) throws SQLException {

		disciplineDAO = new DisciplineDAO();
		disciplineDAO.update(discipline);

	}

	/**
	 * 
	 * @param discipline
	 * @return
	 * @throws SQLException
	 */
	public Discipline search(Discipline discipline) throws SQLException {

		disciplineDAO = new DisciplineDAO();
		return disciplineDAO.search(discipline);

	}

	/**
	 * 
	 * @return
	 * @throws SQLException
	 */
	public ArrayList<Discipline> searchAll() throws SQLException {

		disciplineDAO = new DisciplineDAO();
		return disciplineDAO.searchAll();

	}

	/**
	 * 
	 * @param id
	 * @return
	 * @throws SQLException
	 */
	public Discipline searchById(int id) throws SQLException {

		disciplineDAO = new DisciplineDAO();
		return disciplineDAO.searchById(id);

	}

	/**
	 * 
	 * @return
	 * @throws SQLException
	 */
	public Discipline searchByMaxId() throws SQLException {

		disciplineDAO = new DisciplineDAO();
		return disciplineDAO.searchByMaxId();

	}

	/**
	 * 
	 * @param name
	 * @return
	 * @throws SQLException
	 */
	public ArrayList<Discipline> searchByName(String name) throws SQLException {

		disciplineDAO = new DisciplineDAO();
		return disciplineDAO.searchByName(name);

	}

	/**
	 * 
	 * @param duration
	 * @return
	 * @throws SQLException
	 */
	public ArrayList<Discipline> searchByDuration(int duration)
			throws SQLException {

		disciplineDAO = new DisciplineDAO();
		return disciplineDAO.searchByDuration(duration);

	}
}
